using HKB.Common;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Web;
namespace HKB.Web
{
	public class Watermark
	{
		public string UploadPic(HttpPostedFile UploadPostFile, string UploadFilePath, string UploadFileName, bool NeedSmallPic, bool NeedOriginalPic, int PicWidth, int PicHeight)
		{
			string text = "";
			string strContentType = UploadPostFile.ContentType.ToString();
			string fileName = UploadPostFile.FileName;
			string a = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();
			string[] array = new string[]
			{
				"jpg",
				"gif",
				"jpeg",
				"png"
			};
			bool flag = false;
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string b = array2[i];
				if (a == b)
				{
					flag = true;
					break;
				}
			}
			string result;
			if (UploadPostFile.ContentType.ToLower().IndexOf("image") < 0 || !flag)
			{
				result = "wrong.jpg";
			}
			else
			{
				if (UploadFileName == "")
				{
					Random random = new Random();
					string str = (10 + random.Next(99)).ToString();
					UploadFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + str;
				}
				UploadFileName = UploadFileName + "." + this.GetImageTypeName(strContentType);
				text = UploadFilePath + UploadFileName;
				FileInfo fileInfo = new FileInfo(text);
				if (!fileInfo.Directory.Exists)
				{
					try
					{
						fileInfo.Directory.Create();
					}
					catch
					{
						result = "wrong.jpg";
						return result;
					}
				}
				try
				{
					if (NeedSmallPic)
					{
						string saveFilePath = UploadFilePath + "sum_" + UploadFileName;
						this.CreateSmallPic(UploadPostFile, saveFilePath, 100.0, 80.0);
					}
					if (PicWidth > 0 && PicHeight > 0)
					{
						this.CreateSmallPic(UploadPostFile, text, (double)PicWidth, (double)PicHeight);
						if (NeedOriginalPic)
						{
							string filename = UploadFilePath + "original_" + UploadFileName;
							UploadPostFile.SaveAs(filename);
						}
					}
					else
					{
						UploadPostFile.SaveAs(text);
					}
					result = UploadFileName;
				}
				catch
				{
					result = "wrong.jpg";
				}
			}
			return result;
		}
		public void zzsImgWater(string ImgFile, string WaterImg, string sImgPath, float Alpha, float iScale, int intDistance)
		{
			try
			{
				FileStream fileStream = new FileStream(ImgFile, FileMode.Open);
				BinaryReader binaryReader = new BinaryReader(fileStream);
				byte[] buffer = binaryReader.ReadBytes((int)fileStream.Length);
				binaryReader.Close();
				fileStream.Close();
				MemoryStream stream = new MemoryStream(buffer);
				Image image = Image.FromStream(stream);
				int width = image.Width;
				int height = image.Height;
				Image image2 = new Bitmap(WaterImg);
				int width2 = image2.Width;
				int height2 = image2.Height;
				decimal num = Convert.ToDecimal(iScale);
				decimal d = 0.05m;
				decimal d2 = num - d;
				decimal d3 = num + d;
				int num2 = width2;
				int num3 = height2;
				if (width >= width2 && height >= height2 && width >= height)
				{
					if (width2 > height2)
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7)) || !(Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7) <= d3))
						{
							num2 = Convert.ToInt32(width * num);
							num3 = Convert.ToInt32(width * num / width2 * height2);
						}
					}
					else
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7)) || !(Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7) <= d3))
						{
							num3 = Convert.ToInt32(height * num);
							num2 = Convert.ToInt32(height * num / height2 * width2);
						}
					}
				}
				if (width2 >= width && height2 >= height && width2 >= height2)
				{
					num2 = Convert.ToInt32(width * num);
					num3 = Convert.ToInt32(width * num / width2 * height2);
				}
				if (width2 >= width && height2 <= height && width >= height)
				{
					num2 = Convert.ToInt32(width * num);
					num3 = Convert.ToInt32(width * num / width2 * height2);
				}
				if (width2 <= width && height2 >= height && width >= height)
				{
					num3 = Convert.ToInt32(height * num);
					num2 = Convert.ToInt32(height * num / height2 * width2);
				}
				if (width >= width2 && height >= height2 && width <= height)
				{
					if (width2 > height2)
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7)) || !(Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7) <= d3))
						{
							num2 = Convert.ToInt32(width * num);
							num3 = Convert.ToInt32(width * num / width2 * height2);
						}
					}
					else
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7)) || !(Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7) <= d3))
						{
							num3 = Convert.ToInt32(height * num);
							num2 = Convert.ToInt32(height * num / height2 * width2);
						}
					}
				}
				if (width2 >= width && height2 >= height && width2 <= height2)
				{
					num3 = Convert.ToInt32(height * num);
					num2 = Convert.ToInt32(height * num / height2 * width2);
				}
				if (width2 >= width && height2 <= height && width <= height)
				{
					num2 = Convert.ToInt32(width * num);
					num3 = Convert.ToInt32(width * num / width2 * height2);
				}
				if (width2 <= width && height2 >= height && width <= height)
				{
					num3 = Convert.ToInt32(height * num);
					num2 = Convert.ToInt32(height * num / height2 * width2);
				}
				Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
				bitmap.SetResolution(72f, 72f);
				Graphics graphics = Graphics.FromImage(bitmap);
				graphics.InterpolationMode = InterpolationMode.High;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.Clear(Color.White);
				graphics.DrawImage(image, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel);
				Bitmap bitmap2 = new Bitmap(bitmap);
				bitmap2.SetResolution(image.HorizontalResolution, image.VerticalResolution);
				Graphics graphics2 = Graphics.FromImage(bitmap2);
				graphics2.InterpolationMode = InterpolationMode.High;
				graphics2.SmoothingMode = SmoothingMode.HighQuality;
				ImageAttributes imageAttributes = new ImageAttributes();
				ColorMap[] map = new ColorMap[]
				{
					new ColorMap
					{
						OldColor = Color.FromArgb(255, 0, 255, 0),
						NewColor = Color.FromArgb(0, 0, 0, 0)
					}
				};
				imageAttributes.SetRemapTable(map, ColorAdjustType.Bitmap);
				float[][] array = new float[5][];
				float[][] arg_6B6_0 = array;
				int arg_6B6_1 = 0;
				float[] array2 = new float[5];
				array2[0] = 1f;
				arg_6B6_0[arg_6B6_1] = array2;
				float[][] arg_6CD_0 = array;
				int arg_6CD_1 = 1;
				array2 = new float[5];
				array2[1] = 1f;
				arg_6CD_0[arg_6CD_1] = array2;
				float[][] arg_6E4_0 = array;
				int arg_6E4_1 = 2;
				array2 = new float[5];
				array2[2] = 1f;
				arg_6E4_0[arg_6E4_1] = array2;
				float[][] arg_6F8_0 = array;
				int arg_6F8_1 = 3;
				array2 = new float[5];
				array2[3] = Alpha;
				arg_6F8_0[arg_6F8_1] = array2;
				array[4] = new float[]
				{
					0f,
					0f,
					0f,
					0f,
					1f
				};
				float[][] newColorMatrix = array;
				ColorMatrix newColorMatrix2 = new ColorMatrix(newColorMatrix);
				imageAttributes.SetColorMatrix(newColorMatrix2, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
				int num4 = width - num2;
				int num5 = height - num3;
				int x;
				if (num4 > intDistance)
				{
					x = num4 - intDistance;
				}
				else
				{
					x = num4;
				}
				int y;
				if (num5 > intDistance)
				{
					y = num5 - intDistance;
				}
				else
				{
					y = num5;
				}
				graphics2.DrawImage(image2, new Rectangle(x, y, num2, num3), 0, 0, width2, height2, GraphicsUnit.Pixel, imageAttributes);
				image = bitmap2;
				image.Save(sImgPath, ImageFormat.Jpeg);
				graphics.Dispose();
				graphics2.Dispose();
				image.Dispose();
				image2.Dispose();
			}
			catch
			{
			}
		}
		public void zzsTextWater(string ImgFile, string TextFont, string sImgPath, float hScale, float widthFont, int Alpha, string sFontFamily, bool bFontBold)
		{
			try
			{
				FileStream fileStream = new FileStream(ImgFile, FileMode.Open);
				BinaryReader binaryReader = new BinaryReader(fileStream);
				byte[] buffer = binaryReader.ReadBytes((int)fileStream.Length);
				binaryReader.Close();
				fileStream.Close();
				MemoryStream stream = new MemoryStream(buffer);
				Image image = Image.FromStream(stream);
				int width = image.Width;
				int height = image.Height;
				Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
				bitmap.SetResolution(72f, 72f);
				Graphics graphics = Graphics.FromImage(bitmap);
				graphics.InterpolationMode = InterpolationMode.High;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.DrawImage(image, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel);
				string familyName = "宋体";
				FontStyle style = FontStyle.Regular;
				if (sFontFamily != "")
				{
					familyName = sFontFamily;
				}
				if (bFontBold)
				{
					style = FontStyle.Bold;
				}
				Font font = null;
				SizeF sizeF = default(SizeF);
				int[] array = new int[]
				{
					1000,
					800,
					700,
					650,
					600,
					560,
					540,
					500,
					450,
					400,
					380,
					360,
					340,
					320,
					300,
					280,
					260,
					240,
					220,
					200,
					180,
					160,
					140,
					120,
					100,
					80,
					72,
					64,
					48,
					32,
					28,
					26,
					24,
					20,
					28,
					16,
					14,
					12,
					10,
					8,
					6,
					4,
					2
				};
				for (int i = 0; i < 43; i++)
				{
					font = new Font(familyName, (float)array[i], style);
					sizeF = graphics.MeasureString(TextFont, font);
					if ((float)((ushort)sizeF.Width) < (float)((ushort)width) * widthFont)
					{
						break;
					}
				}
				int num = (int)((float)height * hScale);
				float num2 = (float)(height - num) - sizeF.Height / 2f;
				float num3 = (float)(width / 2);
				StringFormat stringFormat = new StringFormat();
				stringFormat.Alignment = StringAlignment.Center;
				SolidBrush brush = new SolidBrush(Color.FromArgb(Alpha, 0, 0, 0));
				graphics.DrawString(TextFont, font, brush, new PointF(num3 + 1f, num2 + 1f), stringFormat);
				SolidBrush brush2 = new SolidBrush(Color.FromArgb(Alpha, 255, 255, 255));
				graphics.DrawString(TextFont, font, brush2, new PointF(num3, num2), stringFormat);
				bitmap.Save(sImgPath, ImageFormat.Jpeg);
				graphics.Dispose();
				image.Dispose();
				bitmap.Dispose();
			}
			catch
			{
			}
		}
		public void zzsImgTextWater(string ImgFile, string WaterImg, string TextFont, string sImgPath, float ImgAlpha, float imgiScale, int intimgDistance, float texthScale, float textwidthFont, int textAlpha)
		{
			try
			{
				FileStream fileStream = new FileStream(ImgFile, FileMode.Open);
				BinaryReader binaryReader = new BinaryReader(fileStream);
				byte[] buffer = binaryReader.ReadBytes((int)fileStream.Length);
				binaryReader.Close();
				fileStream.Close();
				MemoryStream stream = new MemoryStream(buffer);
				Image image = Image.FromStream(stream);
				int width = image.Width;
				int height = image.Height;
				Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
				bitmap.SetResolution(72f, 72f);
				Graphics graphics = Graphics.FromImage(bitmap);
				graphics.InterpolationMode = InterpolationMode.High;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.DrawImage(image, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel);
				int[] array = new int[]
				{
					1000,
					800,
					700,
					650,
					600,
					560,
					540,
					500,
					450,
					400,
					380,
					360,
					340,
					320,
					300,
					280,
					260,
					240,
					220,
					200,
					180,
					160,
					140,
					120,
					100,
					80,
					72,
					64,
					48,
					32,
					28,
					26,
					24,
					20,
					28,
					16,
					14,
					12,
					10,
					8,
					6,
					4,
					2
				};
				Font font = null;
				SizeF sizeF = default(SizeF);
				for (int i = 0; i < 43; i++)
				{
					font = new Font("arial", (float)array[i], FontStyle.Bold);
					sizeF = graphics.MeasureString(TextFont, font);
					if ((float)((ushort)sizeF.Width) < (float)((ushort)width) * textwidthFont)
					{
						break;
					}
				}
				int num = (int)((float)height * texthScale);
				float num2 = (float)(height - num) - sizeF.Height / 2f;
				float num3 = (float)(width / 2);
				StringFormat stringFormat = new StringFormat();
				stringFormat.Alignment = StringAlignment.Center;
				SolidBrush brush = new SolidBrush(Color.FromArgb(textAlpha, 0, 0, 0));
				graphics.DrawString(TextFont, font, brush, new PointF(num3 + 1f, num2 + 1f), stringFormat);
				SolidBrush brush2 = new SolidBrush(Color.FromArgb(textAlpha, 255, 255, 255));
				graphics.DrawString(TextFont, font, brush2, new PointF(num3, num2), stringFormat);
				Image image2 = new Bitmap(WaterImg);
				int width2 = image2.Width;
				int height2 = image2.Height;
				decimal num4 = Convert.ToDecimal(imgiScale);
				decimal d = 0.05m;
				decimal d2 = num4 - d;
				decimal d3 = num4 + d;
				int num5 = width2;
				int num6 = height2;
				if (width >= width2 && height >= height2 && width >= height)
				{
					if (width2 > height2)
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7)) || !(Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7) <= d3))
						{
							num5 = Convert.ToInt32(width * num4);
							num6 = Convert.ToInt32(width * num4 / width2 * height2);
						}
					}
					else
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7)) || !(Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7) <= d3))
						{
							num6 = Convert.ToInt32(height * num4);
							num5 = Convert.ToInt32(height * num4 / height2 * width2);
						}
					}
				}
				if (width2 >= width && height2 >= height && width2 >= height2)
				{
					num5 = Convert.ToInt32(width * num4);
					num6 = Convert.ToInt32(width * num4 / width2 * height2);
				}
				if (width2 >= width && height2 <= height && width >= height)
				{
					num5 = Convert.ToInt32(width * num4);
					num6 = Convert.ToInt32(width * num4 / width2 * height2);
				}
				if (width2 <= width && height2 >= height && width >= height)
				{
					num6 = Convert.ToInt32(height * num4);
					num5 = Convert.ToInt32(height * num4 / height2 * width2);
				}
				if (width >= width2 && height >= height2 && width <= height)
				{
					if (width2 > height2)
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7)) || !(Math.Round(Convert.ToDecimal(width2) / Convert.ToDecimal(width), 7) <= d3))
						{
							num5 = Convert.ToInt32(width * num4);
							num6 = Convert.ToInt32(width * num4 / width2 * height2);
						}
					}
					else
					{
						if (!(d2 <= Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7)) || !(Math.Round(Convert.ToDecimal(height2) / Convert.ToDecimal(height), 7) <= d3))
						{
							num6 = Convert.ToInt32(height * num4);
							num5 = Convert.ToInt32(height * num4 / height2 * width2);
						}
					}
				}
				if (width2 >= width && height2 >= height && width2 <= height2)
				{
					num6 = Convert.ToInt32(height * num4);
					num5 = Convert.ToInt32(height * num4 / height2 * width2);
				}
				if (width2 >= width && height2 <= height && width <= height)
				{
					num5 = Convert.ToInt32(width * num4);
					num6 = Convert.ToInt32(width * num4 / width2 * height2);
				}
				if (width2 <= width && height2 >= height && width <= height)
				{
					num6 = Convert.ToInt32(height * num4);
					num5 = Convert.ToInt32(height * num4 / height2 * width2);
				}
				Bitmap bitmap2 = new Bitmap(bitmap);
				bitmap2.SetResolution(image.HorizontalResolution, image.VerticalResolution);
				Graphics graphics2 = Graphics.FromImage(bitmap2);
				graphics2.InterpolationMode = InterpolationMode.High;
				graphics2.SmoothingMode = SmoothingMode.HighQuality;
				ImageAttributes imageAttributes = new ImageAttributes();
				ColorMap[] map = new ColorMap[]
				{
					new ColorMap
					{
						OldColor = Color.FromArgb(255, 0, 255, 0),
						NewColor = Color.FromArgb(0, 0, 0, 0)
					}
				};
				imageAttributes.SetRemapTable(map, ColorAdjustType.Bitmap);
				float[][] array2 = new float[5][];
				float[][] arg_7B1_0 = array2;
				int arg_7B1_1 = 0;
				float[] array3 = new float[5];
				array3[0] = 1f;
				arg_7B1_0[arg_7B1_1] = array3;
				float[][] arg_7C8_0 = array2;
				int arg_7C8_1 = 1;
				array3 = new float[5];
				array3[1] = 1f;
				arg_7C8_0[arg_7C8_1] = array3;
				float[][] arg_7DF_0 = array2;
				int arg_7DF_1 = 2;
				array3 = new float[5];
				array3[2] = 1f;
				arg_7DF_0[arg_7DF_1] = array3;
				float[][] arg_7F3_0 = array2;
				int arg_7F3_1 = 3;
				array3 = new float[5];
				array3[3] = ImgAlpha;
				arg_7F3_0[arg_7F3_1] = array3;
				array2[4] = new float[]
				{
					0f,
					0f,
					0f,
					0f,
					1f
				};
				float[][] newColorMatrix = array2;
				ColorMatrix newColorMatrix2 = new ColorMatrix(newColorMatrix);
				imageAttributes.SetColorMatrix(newColorMatrix2, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
				int num7 = width - num5;
				int num8 = height - num6;
				int x;
				if (num7 > intimgDistance)
				{
					x = num7 - intimgDistance;
				}
				else
				{
					x = num7;
				}
				int y;
				if (num8 > intimgDistance)
				{
					y = num8 - intimgDistance;
				}
				else
				{
					y = num8;
				}
				graphics2.DrawImage(image2, new Rectangle(x, y, num5, num6), 0, 0, width2, height2, GraphicsUnit.Pixel, imageAttributes);
				image = bitmap2;
				image.Save(sImgPath, ImageFormat.Jpeg);
				graphics.Dispose();
				graphics2.Dispose();
				bitmap.Dispose();
				image.Dispose();
				image2.Dispose();
			}
			catch
			{
			}
		}
		public bool CreateSmallPic(HttpPostedFile UploadPostFile, string SaveFilePath, double XWidth, double XHeight)
		{
			bool result = true;
			Image image = Image.FromStream(UploadPostFile.InputStream, true);
			string strContentType = UploadPostFile.ContentType.ToString();
			double num = XWidth;
			double num2 = XHeight;
			if ((double)image.Width < num)
			{
				num = (double)image.Width;
			}
			if ((double)image.Height < num2)
			{
				num2 = (double)image.Height;
			}
			double num3;
			double num4;
			if (image.Width > image.Height)
			{
				num3 = num;
				num4 = (double)image.Height * (num3 / (double)image.Width);
			}
			else
			{
				num4 = num2;
				num3 = num4 / (double)image.Height * (double)image.Width;
			}
			if (num3 > num)
			{
				num3 = num;
			}
			if (num4 > num2)
			{
				num4 = num2;
			}
			Size size = new Size((int)num3, (int)num4);
			Image image2 = new Bitmap(size.Width, size.Height);
			Graphics graphics = Graphics.FromImage(image2);
			graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
			graphics.SmoothingMode = SmoothingMode.HighQuality;
			graphics.Clear(Color.White);
			graphics.DrawImage(image, new Rectangle(0, 0, image2.Width, image2.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
			try
			{
				image2.Save(SaveFilePath, this.GetImageType(strContentType));
			}
			catch
			{
				result = false;
			}
			graphics.Dispose();
			image.Dispose();
			image2.Dispose();
			return result;
		}
		public bool CreateSmallPic(string ImgFile, string sImgPath, int ResizeWidth, int ResizeHeight, string BgColor)
		{
			bool result;
			try
			{
				FileStream fileStream = new FileStream(ImgFile, FileMode.Open);
				BinaryReader binaryReader = new BinaryReader(fileStream);
				byte[] buffer = binaryReader.ReadBytes((int)fileStream.Length);
				binaryReader.Close();
				fileStream.Close();
				MemoryStream stream = new MemoryStream(buffer);
				Image image = Image.FromStream(stream);
				int width = image.Width;
				int height = image.Height;
				int x = 0;
				int y = 0;
				int num = 0;
				int num2 = 0;
				if (width >= ResizeWidth && height >= ResizeHeight)
				{
					num = ResizeWidth;
					num2 = Convert.ToInt32(height * Math.Round(Convert.ToDecimal(ResizeWidth) / Convert.ToDecimal(width), 10));
					x = 0;
					y = (ResizeHeight - num2) / 2;
				}
				if (ResizeWidth > width && ResizeHeight < height)
				{
					num2 = ResizeHeight;
					num = Convert.ToInt32(width * Math.Round(Convert.ToDecimal(ResizeHeight) / Convert.ToDecimal(height), 10));
					x = (ResizeWidth - num) / 2;
					y = 0;
				}
				if (ResizeWidth < width && ResizeHeight > height)
				{
					num = ResizeWidth;
					num2 = Convert.ToInt32(height * Math.Round(Convert.ToDecimal(ResizeWidth) / Convert.ToDecimal(width), 10));
					x = 0;
					y = (ResizeHeight - num2) / 2;
				}
				if (width < ResizeWidth && height < ResizeHeight)
				{
					num = width;
					num2 = height;
					x = (ResizeWidth - width) / 2;
					y = (ResizeHeight - height) / 2;
				}
				Bitmap bitmap = new Bitmap(ResizeWidth, ResizeHeight, PixelFormat.Format24bppRgb);
				bitmap.SetResolution(72f, 72f);
				Graphics graphics = Graphics.FromImage(bitmap);
				graphics.Clear(Color.FromName(BgColor));
				graphics.InterpolationMode = InterpolationMode.High;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.DrawImage(image, new Rectangle(x, y, num, num2), new Rectangle(0, 0, width, height), GraphicsUnit.Pixel);
				bitmap.Save(sImgPath, ImageFormat.Jpeg);
				image.Dispose();
				graphics.Dispose();
				bitmap.Dispose();
			}
			catch
			{
				result = false;
				return result;
			}
			result = true;
			return result;
		}
		public bool CreateSmallPic(string ImgFile, string sImgPath, int ResizeWidth, int ResizeHeight)
		{
			bool result;
			try
			{
				Image image = Image.FromFile(Fetch.GetTruePath(ImgFile));
				Image.GetThumbnailImageAbort callback = new Image.GetThumbnailImageAbort(this.ThumbnailCallback);
				int num = image.Width;
				int num2 = image.Height;
				if (num > ResizeWidth || num2 > ResizeHeight)
				{
					if (num > ResizeWidth)
					{
						num2 = num2 * ResizeWidth / num;
						num = ResizeWidth;
					}
					if (num2 > ResizeHeight)
					{
						num = num * ResizeHeight / num2;
						num2 = ResizeHeight;
					}
				}
                Image thumbnailImage = image.GetThumbnailImage(num, num2, callback, new System.IntPtr(0)); //TODO:有修改参数
				thumbnailImage.Save(Fetch.GetTruePath(sImgPath));
				image.Dispose();
			}
			catch
			{
				result = false;
				return result;
			}
			result = true;
			return result;
		}
		private bool ThumbnailCallback()
		{
			return false;
		}
		public void zzsCutImg(string ImgFile, string sImgPath, int PointX, int PointY, int CutWidth, int CutHeight)
		{
			try
			{
				FileStream fileStream = new FileStream(ImgFile, FileMode.Open);
				BinaryReader binaryReader = new BinaryReader(fileStream);
				byte[] buffer = binaryReader.ReadBytes((int)fileStream.Length);
				binaryReader.Close();
				fileStream.Close();
				MemoryStream stream = new MemoryStream(buffer);
				Image image = Image.FromStream(stream);
				Bitmap bitmap = new Bitmap(CutWidth, CutHeight, PixelFormat.Format24bppRgb);
				bitmap.SetResolution(72f, 72f);
				Graphics graphics = Graphics.FromImage(bitmap);
				graphics.InterpolationMode = InterpolationMode.High;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.DrawImage(image, new Rectangle(0, 0, CutWidth, CutHeight), new Rectangle(PointX, PointY, CutHeight, CutHeight), GraphicsUnit.Pixel);
				bitmap.Save(sImgPath, ImageFormat.Jpeg);
				image.Dispose();
				graphics.Dispose();
				bitmap.Dispose();
			}
			catch
			{
			}
		}
		private ImageFormat GetImageType(string strContentType)
		{
			ImageFormat result;
			if (strContentType.ToLower() == "image/pjpeg")
			{
				result = ImageFormat.Jpeg;
			}
			else
			{
				if (strContentType.ToLower() == "image/gif")
				{
					result = ImageFormat.Gif;
				}
				else
				{
					if (strContentType.ToLower() == "image/bmp")
					{
						result = ImageFormat.Bmp;
					}
					else
					{
						if (strContentType.ToLower() == "image/x-png")
						{
							result = ImageFormat.Png;
						}
						else
						{
							result = ImageFormat.MemoryBmp;
						}
					}
				}
			}
			return result;
		}
		private string GetImageTypeName(string strContentType)
		{
			string result;
			if (strContentType.ToLower() == "image/pjpeg")
			{
				result = "jpg";
			}
			else
			{
				if (strContentType.ToLower() == "image/gif")
				{
					result = "gif";
				}
				else
				{
					if (strContentType.ToLower() == "image/bmp")
					{
						result = "bmp";
					}
					else
					{
						if (strContentType.ToLower() == "image/x-png")
						{
							result = "png";
						}
						else
						{
							result = "bmp";
						}
					}
				}
			}
			return result;
		}
	}
}
